using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMoveState : PlayerGroundState
{
    public PlayerMoveState(Player player, PlayerMoveData playerData, StateMachine stateMachine, string animBoolName) : base(player, playerData, stateMachine, animBoolName)
    { 
    }

    private bool isFast = false;

    public override void LogicUpdate()
    {
        base.LogicUpdate();
        if (stateMachine.CurrentState != this) { return; }

        player.CheckIfNeedFlip(xInput);
        if (fastMoveInput)
        {
            if (!isFast) 
            {
                isFast = true;
                player.animator.Play("MoveFast");
            }
            player.SetVelocityX(playerData.movementVelocity * playerData.fastMoveMultiplier * player.FacingDirection);
        }
        else 
        {
            if (isFast)
            {
                player.animator.Play("Move");
                isFast = false;
            }
            player.SetVelocityX(playerData.movementVelocity * player.FacingDirection);
        }
        
        if (yInput == -1)
        {
            stateMachine.ChangeState(player.CrouchMoveState);
        }
        else if (xInput == 0)
        {
            stateMachine.ChangeState(player.IdleState);
        }

    }
}
